using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyHocPhi.Model.Mapping
{
    public class LopGocMap : EntityTypeConfiguration<LopGoc>
    {
        public LopGocMap()
        {
            // Primary Key
            this.HasKey(t => t.MaLopGoc);

            // Properties
            this.Property(t => t.MaLopGoc)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TenLopGoc)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.NamTuyenSinh)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.MaLoaiHinhDaoTao)
                .IsRequired()
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("LopGoc");
            this.Property(t => t.MaLopGoc).HasColumnName("MaLopGoc");
            this.Property(t => t.TenLopGoc).HasColumnName("TenLopGoc");
            this.Property(t => t.NamTuyenSinh).HasColumnName("NamTuyenSinh");
            this.Property(t => t.MaLoaiHinhDaoTao).HasColumnName("MaLoaiHinhDaoTao");

            // Relationships
            this.HasRequired(t => t.LoaiHinhDaoTao)
                .WithMany(t => t.LopGocList)
                .HasForeignKey(d => d.MaLoaiHinhDaoTao);

        }
    }
}
